package com.situ.ssm.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.ssm.common.ServerResponse;
import com.situ.ssm.entity.User;
import com.situ.ssm.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	private IUserService userService;
	
	@RequestMapping("/getUserListPage")
	public String getUserListPage() {
		return "user_list";
	}
	
	// /user/pageList.action?page=1&limit=30
	@RequestMapping("/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page, Integer limit, User user) {
		return userService.pageList(page, limit, user);
	}
	
	@RequestMapping("/deleteById")
	@ResponseBody
	public ServerResponse deleteById(Integer id) {
		return userService.deleteById(id);
	}
	
	@RequestMapping("/deleteAll")
	@ResponseBody
	public ServerResponse deleteAll(Integer[] ids) {
		// ids: 40,41
		System.out.println(Arrays.toString(ids));// [40, 41]
		return userService.deleteAll(ids);
	}
	
}
